<template>
	<view>
		<view class="top">
			<view class="text">
				<view class="title">标题：</view>
				<view class="info">{{ Rules.title }}</view>
			</view>
			<view class="text">
				<view class="title">考试标准：</view>
				<view class="info">{{ Rules.timeHours }} 分钟, {{Rules.numtotal}} 题</view>
			</view>
			<view class="text">
				<view class="title">合格标准：</view>
				<view class="info">{{standard}}</view>
			</view>
			<view class="text">
				<view class="title">描述：</view>
				<view class="u-content">
					<u-parse :content="Rules.descriptions"></u-parse>
				</view>
			</view>
			<view class="text">
				<view class="title">图片：</view>
				<u--image :showLoading="true" :src="Rules.cover" width="80px" height="80px"></u--image>
			</view>
		</view>
		<view @click="go" class="bott">
			<view class="sub">开始测试</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Rules:{
					
				},
				title: '测试题库',
				qualified: '40分合格（满分50）',
				descriptions: '<p>测试计划</p>',
				cover: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.baidu.com%2Fit%2Fu%3D3062469291%2C1117322059%26fm%3D253%26app%3D120%26f%3DJPEG%3Fw%3D1200%26h%3D800&refer=http%3A%2F%2Fimg2.baidu.com&app=2002&size=w300&q=a80&n=0&g=0n&fmt=jpeg',
				id: null
			}
		},
		onLoad(params) {
			this.id = params.id
			this.init()
		},
		computed:
		{
			standard()
			{
				return  this.Rules.scoreTotal*0.6 +"及格,满分"+this.Rules.scoreTotal;
			}
		},
		methods: {
			init() {
				uni.$u.http.get('/app/paper/getRules/' + this.id).then((res) => {
					if(res.code==0)
					{
						this.Rules = res.data
					}
				})
			},
			go() {
				uni.$u.http.get('/app/paper/Expire/' + this.id).then((res) => {
					console.log(res);

					if (res.time != -2) {
						uni.showModal({
							title: '',
							content: '你已开始测试，是否选择重新测试，还是继续之前的作答',
							success: (res)=> {
								if (res.confirm) {
									let newdata = {
										type: 1,
										id: this.id
									}

									uni.navigateTo({
										url: './exam?id=' + JSON.stringify(newdata)
									})
								} else if (res.cancel) {
									let newdata = {
										type: 2,
										id: this.id
									}
									//当你选中重现开始的时候就可以将用户的 作答计入删除并且，更新时间

									uni.$u.http.get('/app/paper/Question/' + this.id).then((res) => {})
									uni.navigateTo({
										url: './exam?id=' + JSON.stringify(newdata)
									})

								}
							}
						});
					} else {
						let newdata = {
							type: 2,
							id: this.id
						}
						//开始设置考试时间
						uni.$u.http.get('/app/paper/Question/' + 22).then((res) => {})
						uni.navigateTo({
							url: './exam?id=' + JSON.stringify(newdata)
						})
					}

				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background: linear-gradient(180deg, #FFFFFF 0%, #F5F5F5 100%);
		background-attachment: fixed;
	}

	.top {
		min-height: 500rpx;
		box-shadow: 1px 3px 6px 1px #d5d5d5;
		border-radius: 10px;
		margin: 10px 15px 0;
		background-color: #fff;
		font-size: 14px;

		.text {
			line-height: 35px;
			display: flex;
			margin-left: 20px;
		}

		.con {
			margin-top: 15px;
			margin-left: 20px;
			font-size: 12px;
			color: #999;
		}
	}

	.bott {
		margin: 20px auto;
		width: 90%;
		height: 40px;

		.sub {
			line-height: 40px;
			text-align: center;
			width: 100%;
			height: 100%;
			border-radius: 20px;
			background: linear-gradient(90deg, #26C3FD 0, #3F8EFF 100%);
		}
	}
</style>
